package com.tools.scanner.ui.qrcode.scanner

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import com.google.mlkit.vision.barcode.common.Barcode
import com.tools.scanner.R
import com.tools.scanner.databinding.FragmentSmsScannerBinding
import com.tools.scanner.utils.sendSms

class SmsFragment : BaseScannerFragment() {

    private lateinit var mBinding: FragmentSmsScannerBinding

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View {
        mBinding = FragmentSmsScannerBinding.inflate(inflater, container, false)
        return mBinding.root
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)

        val smsInfo = getData(Barcode.Sms::class.java) ?: return

        mBinding.tvPhone.text = smsInfo.phoneNumber
        mBinding.tvContent.text = smsInfo.message

        mBinding.tvSend.setOnClickListener {
            smsInfo.sendSms()
        }
    }

}